package com.xs.integratedpraiseconsumer.listener;


import com.xs.integratedpraiseconsumer.message.PraiseMessage;
import com.xs.integratedpraiseconsumer.service.PraiseService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;

import java.util.function.Consumer;

@Configuration
public class ListenerAutoConfiguration {
    @Bean
    public Consumer<Message<PraiseMessage>> consumer(PraiseService praiseService) {
        return message -> {
            praiseService.praiseItem(message.getPayload().getItemId());
        };
    }
}
